import java.awt.BorderLayout;
import java.awt.Color;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class UserBarPanel extends JPanel {
	public ImageIcon icon;

	public JLabel empty;
	public JLabel username;
	public JLabel ranking;

	public Color c1, c2, c3, c4, c5, c6;

	public UserBarPanel() {
		colorOff();

		this.setBackground(c1);
		this.setLayout(new BorderLayout());
		this.setBorder(BorderFactory.createCompoundBorder(
				BorderFactory.createCompoundBorder(BorderFactory
						.createMatteBorder(2, 2, 0, 2, c2), BorderFactory
						.createMatteBorder(1, 1, 2, 2, c3)), BorderFactory
						.createMatteBorder(3, 3, 3, 3, c4)));

		empty = new JLabel("  ");
		this.add(empty, BorderLayout.WEST);

		username = new JLabel();
		username.setForeground(Color.white);
		this.add(username, BorderLayout.CENTER);

		ranking = new JLabel();
		ranking.setForeground(Color.yellow);
		this.add(ranking, BorderLayout.EAST);

		this.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseEntered(java.awt.event.MouseEvent evt) {
				setBackground(c5);
			}

			public void mouseExited(java.awt.event.MouseEvent evt) {
				setBackground(c1);
			}

			public void mouseClicked(java.awt.event.MouseEvent evt) {
			}
		});

	}

	public void on(String arg1, String arg2, int arg3) {
		setIcon(arg1);
		setUsername(arg2);
		setRanking(arg3);
		colorOn();
	}
	public void off(){
		setIcon(null);
		setUsername(null);
		setRanking("");
		colorOff();
	}

	public void colorOn() {
		c1 = new Color(25, 25, 25);
		c2 = new Color(43, 43, 43);
		c3 = new Color(15, 15, 15);
		c4 = new Color(55, 55, 55);
		c5 = Color.black;

		set();
	}

	public void colorOff() {
		Color ctmp = new Color(43, 43, 43);
		c1 = ctmp;
		c2 = ctmp;
		c3 = ctmp;
		c4 = ctmp;
		c5 = ctmp;

		set();
	}

	public void set() {
		this.setBackground(c1);
		this.setBorder(BorderFactory.createCompoundBorder(
				BorderFactory.createCompoundBorder(BorderFactory
						.createMatteBorder(2, 2, 0, 2, c2), BorderFactory
						.createMatteBorder(1, 1, 2, 2, c3)), BorderFactory
						.createMatteBorder(3, 3, 3, 3, c4)));
	}

	public void setIcon(String arg1) {
		username.setIcon(new ImageIcon(arg1 + ".png"));
	}

	public void setUsername(String arg1) {
		username.setText(arg1);
	}

	public void setRanking(String arg1) {
		ranking.setText(arg1 + "  ");
	}

	public void setRanking(int arg1) {
		setRanking(arg1 + "");
	}
}
